import config from "@/common/config/config.js"
import utils from "@/common/utils/utils.js"

function gotoMoviceDetail(movice){
	console.log(JSON.stringify(movice));
	let ep = encodeURIComponent(JSON.stringify(movice));
	let userInfo = uni.getStorageSync('userInfo');
	if (userInfo.user_status != '1' && userInfo.user_answer.length == 0){
		return 'failed';
	}else if (userInfo.user_status == '1') {
		uni.navigateTo({
			url: '/pages/play/main?params=' + ep
		});
	} else {
		uni.navigateTo({
			url: '/pages/videodetail/main?params=' + ep
		});
	}
}

function gotoSkinInfo(item,callback){
	let userInfo = uni.getStorageSync("userInfo");
	console.log(userInfo);
	if(userInfo.user_points >= 100){
		
	}else{
		if(callback)callback()
		return;
	}
	if (item.skin_activity_status == 0) {
		if(userInfo.user_pid == null || userInfo.user_pid.length == 0 || userInfo.user_pid == 0){
			// if(callback)callback()
			return;
		}
		
		let ep = encodeURIComponent(JSON.stringify({"skin_activity_id":item.skin_activity_id}));
		uni.navigateTo({
			url:'/pages/gameskin/skinDetail?params=' + ep
		})
	} else if (item.skin_status == 0 && item.accessWay != null && item.accessWay.length > 0) {
		uni.showToast({
			title: item.accessWay,
			icon: 'none',
			duration: 2000
		})
	} else {
		uni.showToast({
			title: '活动未开始',
			icon: 'none',
			duration: 2000
		})
	}
}

function reLaunchTosubpackagesRoot(data){
	let ep = encodeURIComponent(JSON.stringify(data));
	uni.reLaunch({
		url: '/redpackage/pages/redpackage/main?params='+ ep
	})
}

function reLaunchToHome(){
	uni.reLaunch({
		url: '/pages/index/index'
	});
}

export default{
	gotoMoviceDetail,
	reLaunchTosubpackagesRoot,
	reLaunchToHome,
	gotoSkinInfo
}